-- ** Locale **--

local L = {}
if (GetLocale() == "zhCN") then
L ={
	["Search"]	= "搜索",
	["MinLvL"]	= "Lv >",
	["MaxLvL"]	= "Lv <",

	["All Armor"]	= "全部",
	["Cloth"]	= "布甲",
	["Leather"]	= "皮甲",
	["Mail"]	= "锁甲",
	["Plate"]	= "板甲",

	["All Slots"]	= "全部",
	["Two-Hand"]	= "双手",
	["Ammo"]	= "弹药",
	["Bag"]	= "背包",
	["Shirt"]	= "衬衣",
	["Chest"]	= "胸部",
	["Back"]	= "背部",
	["Feet"]	= "脚",
	["Finger"]	= "手指",
	["Hands"]	= "手",
	["Head"]	= "头部",
	["Held In Off-hand"]	= "副手物品",
	["Legs"]	= "腿部",
	["Neck"]	= "颈部",
	["Quiver"]	= "箭袋",
	["Ranged"]	= "远程",
	["RangedRight"]	= "远程",
	["Relic"]	= "圣物",
	["Robe"]	= "胸部",
	["Shield"]	= "副手",
	["Shoulder"]	= "肩部",
	["Tabard"]	= "战袍",
	["Thrown"]	= "投掷",
	["Trinket"]	= "饰品",
	["Waist"]	= "腰部",
	["One-Hand"]	= "单手",
	["Main Hand"]	= "主手",
	["Off Hand"]	= "副手",
	["Wrist"]	= "手腕",
}
--elseif (GetLocale() == "zhTW") then	
else
L = {
	["Search"] = "Search",
	["MinLvL"] = "MinLvL",
	["MaxLvL"] = "MaxLvL",
	["All Armor"] = "All Armor",
	["Cloth"] = "Cloth",
	["Leather"] = "Leather",
	["Mail"] = "Mail",
	["Plate"] = "Plate",
	["All Slots"]	= "All Slots",
	["Two-Hand"]	= "Two-Hand",
	["Ammo"]	= "Ammo",
	["Bag"]	= "Bag",
	["Shirt"]	= "Shirt",
	["Chest"]	= "Chest",
	["Back"]	= "Back",
	["Feet"]	= "Feet",
	["Finger"]	= "Finger",
	["Hands"]	= "Hands",
	["Head"]	= "Head",
	["Held In Off-hand"]	= "Held In Off-hand",
	["Legs"]	= "Legs",
	["Neck"]	= "Neck",
	["Quiver"]	= "Quiver",
	["Ranged"]	= "Ranged",
	["RangedRight"]	= "RangedRight",
	["Relic"]	= "Relic",
	["Robe"]	= "Robe",
	["Shield"]	= "Shield",
	["Shoulder"]	= "Shoulder",
	["Tabard"]	= "Tabard",
	["Thrown"]	= "Thrown",
	["Trinket"]	= "Trinket",
	["Waist"]	= "Waist",
	["One-Hand"]	= "One-Hand",
	["Main Hand"]	= "Main Hand",
	["Off Hand"]	= "Off Hand",
	["Wrist"]	= "Wrist",
}
end

-- ** Variable Declaration - Non Saved**

local RunCounter = 0
local ShowItem
local iName, iLink, iQuality, iLevel, iReqLevel, iType, iSubType, iMaxStack, iEqupSlot, iTexture
local CurrentTab				-- Currently active guild bank tab
local FrameOverlay ={} 					-- Array for overlay frames
local FrameName 			-- Used for building unique frame names
local OverlayFrameName 
local OverlayFrameTextureName

-- Standard BCS Addon Functions / Variables
local bcsDebug = nil			-- BCS Debug Output , bcsDebug ==1 for Debug Text, ==2 for Debug Text plus Debug Call Stack Information
local DebugMsg = nil			-- String for holding the outgoing message when in debug mode ~= nil
local OutMsg = nil				-- String for holding the outgoing message for general usage
local cmd = nil					-- cmd for holding the string after the /<addon name> 
local ArgCounter = nil 		-- Argument counter for when using ... for variable arguments
local elapsed = 0 				-- Delay counter for OnUpdate


-- Start of Function definitions
local function DOut(...)  -- BCS Debug Output , bcsDebug ==1 for Debug Text, ==2 for Debug Text plus Debug Call Stack Information
	if bcsDebug ~= nil then
		DebugMsg = "|cFEFED000GBF,"
		for ArgCounter = 1, select("#", ...) do -- counter for number of args passed to function using ... so that variable number of args may be used.
			if select(ArgCounter, ...) ~= nil then
				DebugMsg = DebugMsg .. "|cFEFED000 DebugMsg arg" .. ArgCounter .. ": |cFF00FFFF" .. select(ArgCounter, ...)
			else 
				DebugMsg = DebugMsg .. "|cFEFED000 DebugMsg arg" .. ArgCounter .. ": |cFF00FFFFnil"
			end
		end
		if bcsDebug > 1 then 
			DebugMsg = DebugMsg .. "\n|cFFCC00FF" .. debugstack()
		end
		DEFAULT_CHAT_FRAME:AddMessage(DebugMsg)
	end
end

local function Out(...)  -- BCS Standard Output Function
	OutMsg = nil
	for ArgCounter = 1, select("#", ...) do
		if select(ArgCounter, ...) ~= nil then
			if OutMsg == nil then
				OutMsg = select(ArgCounter, ...) 
			else
				OutMsg = OutMsg .. select(ArgCounter, ...) 
			end
		end
	end
	if OutMsg ~= nil then 
		DEFAULT_CHAT_FRAME:AddMessage(OutMsg) 
	else
		if bcsDebug > 1 then
			DEFAULT_CHAT_FRAME:AddMessage("Passed String to Standard Msg Handler was nil " .. debugstack()) 
		elseif bcsDebug ~= nil then 
			DEFAULT_CHAT_FRAME:AddMessage("Passed String to Standard Msg Handler was nil ") 
		end
	end
end

function GBF_OnEvent(this, event, ...)  -- BCS Standard event handler function
	if bcsDebug ~= nil then
		GBFEventMsg = "|cFF00FF00GBF, Event Msg:|cFF00FFFF" .. event 
		for ArgCounter = 1, select("#", ...) do 
			if select("#", ...) ~= nil then
				GBFEventMsg = GBFEventMsg .. "|cFEFED000 Event arg" .. ArgCounter .. ": |cFF00FFFF" .. select(ArgCounter, ...)
			end
		end
		if bcsDebug > 1 then 
			GBFEventMsg = GBFEventMsg .. "\n|cFFCC00FF" .. debugstack()
		else
			DEFAULT_CHAT_FRAME:AddMessage(GBFEventMsg)
		end
	end
	if event == "GUILDBANKBAGSLOTS_CHANGED" and GuildBankFrame:IsVisible() then
        if DDItemSubTypeMenu == nil then
			DDItemSubTypeMenuCreation()
			UIDropDownMenu_SetSelectedValue(DDItemSubTypeMenu,0)
			DDItemSlotMenuCreation()
			UIDropDownMenu_SetSelectedValue(DDItemSlotMenu,0)  -- Sets Default value of dropdown to entry 0
			GBFSearchFrameCreate()
			GBFMiniLvLFrameCreate()
			GBFMaxiLvLFrameCreate()
		end		
		GBFGuildBankUpdate()
	end
end

--  ** Slash Command Handler Function - None Declared **
--[[ 
function bcsGBF_Command(cmd)
	cmd = strlower(cmd)
  	if  (cmd ~= nil and cmd ~= "") then
  		Out("GBF Command: " .. cmd);
  		if cmd == "on" then
  			Out("GBF Now Enabled");
 		elseif cmd=="off" then
  			Out("GBF Now Disabled");
    		else
  			Out("Command /GBF " .. cmd .. " is not a valid option");
  		end	
  	else
		Out("GBF on - Enable GBF addon");
		Out("GBF off - Disable GBF addon");  				
	end
end
]]--

function GBFGuildBankUpdate()
	RunCounter=RunCounter+1
	DOut("Running Function GBFGuildBankUpdate for the " .. RunCounter .. " time")
	CurrentTab=GetCurrentGuildBankTab()
	for  ColCounter = 1, 7 do
		for  ButtonCounter = 1 , 14 do
			FrameName = "GuildBankColumn" .. ColCounter .."Button".. ButtonCounter 
			OverlayFrameName = FrameName .. "Overlay"
			OverlayFrameTextureName= FrameName .. "Texture"
			FrameNameReqLVL = FrameName .. "ReqLVL"
			if  FrameOverlay[OverlayFrameName]==nil then
				FrameOverlay[OverlayFrameName]=CreateFrame("FRAME",FrameOverlay[OverlayFrameName],_G[FrameName]);
				FrameOverlay[OverlayFrameName]:SetWidth(35); FrameOverlay[OverlayFrameName]:SetHeight(35)
				FrameOverlay[OverlayFrameName]:SetPoint("CENTER",_G[FrameName])
				FrameOverlay[OverlayFrameTextureName]=FrameOverlay[OverlayFrameName]:CreateTexture()
				FrameOverlay[OverlayFrameTextureName]:SetTexture(0,0,0)
				FrameOverlay[OverlayFrameTextureName]:SetAlpha(.75)
				FrameOverlay[OverlayFrameTextureName]:SetAllPoints()

			end
			if  FrameOverlay[FrameNameReqLVL] == nil then
				FrameOverlay[FrameNameReqLVL]=_G[FrameName]:CreateFontString("$parentText","ARTWORK","SystemFont_Outline_Small")
				FrameOverlay[FrameNameReqLVL]:SetPoint("TOPLEFT",_G[FrameName],"TOPLEFT")
			end

--			Equipable = IsEquippableItem(GetGuildBankItemLink(CurrentTab,( (((ColCounter-1)*14)+ButtonCounter) )))

			if GetGuildBankItemLink(CurrentTab,( (((ColCounter-1)*14)+ButtonCounter) )) ~= nil then
				iName, iLink, iQuality, iLevel, iReqLevel, iType, iSubType, iMaxStack, iEqupSlot, iTexture = GetItemInfo(GetGuildBankItemLink(CurrentTab,( (((ColCounter-1)*14)+ButtonCounter) )))  -- ** EDIT FIXED TAB NUMBER **

				ShowItem=1
				if FilterSubType ~= nil  then
					if FilterSubType ~= iSubType then
						ShowItem = nil
					end
				end
				if SearchEditBox:GetText() ~= "" then
					if string.match(strlower(iName),strlower(SearchEditBox:GetText()))  == nil then
						ShowItem = nil
					end
				end
				if ((tonumber(MiniLvLEditBox:GetText()) ~= nil) and (iReqLevel < tonumber(MiniLvLEditBox:GetText()))) then
						ShowItem = nil
				end
				if ((tonumber(MaxiLvLEditBox:GetText()) ~= nil) and (iReqLevel > tonumber(MaxiLvLEditBox:GetText()))) then
						ShowItem = nil
				end
				if ((FilterSlot ~= nil) and (FilterSlot ~= iEqupSlot)) then
						ShowItem = nil
				end
				if ShowItem == 1 then
					FrameOverlay[OverlayFrameName]:SetBackdropColor(0,0,0,0)
					FrameOverlay[OverlayFrameName]:Hide()
				else	
					FrameOverlay[OverlayFrameName]:SetBackdropColor(0,0,0,1)
					FrameOverlay[OverlayFrameName]:Show()
				end
				if iReqLevel ~= 0 then 
					FrameOverlay[FrameNameReqLVL]:SetText("|cFEFED000"..iReqLevel)
					FrameOverlay[FrameNameReqLVL]:Show()
				else
					FrameOverlay[FrameNameReqLVL]:Hide()
				end
			else  -- if nothing in bank slot
				FrameOverlay[OverlayFrameName]:Hide()
				FrameOverlay[FrameNameReqLVL]:Hide()
			end
		end
	end
end

function GBFSearchFrameCreate()
	SearchLabel=GuildBankFrame:CreateFontString("$parentText","ARTWORK","SystemFont_Outline_Small")
	SearchLabel:SetPoint("TOPLEFT",GuildBankFrame,"TOPLEFT",30,-47)
	SearchLabel:SetText(L["Search"])
	SearchEditBox=CreateFrame("EditBox","SearchEditBox",GuildBankFrame,"InputBoxTemplate")
	SearchEditBox:SetWidth(80);SearchEditBox:SetHeight(20)
	SearchEditBox:SetPoint("TOPLEFT",GuildBankFrame,"TOPLEFT",75,-42)
	SearchEditBox:EnableMouse(true)
	SearchEditBox:SetMultiLine(false)
	SearchEditBox:SetAutoFocus(false)
	SearchEditBox:SetFontObject(GameFontNormalSmall)
	SearchEditBox:SetJustifyH("LEFT") 
	SearchEditBox:RegisterEvent("OnEnterPressed")
	SearchEditBox:SetScript("OnEnterPressed", function() SearchEditBox:ClearFocus()  GBFGuildBankUpdate() end )
	SearchEditBox:RegisterEvent("OnEscapePressed")
	SearchEditBox:SetScript("OnEscapePressed", function() SearchEditBox:ClearFocus()  SearchEditBox:SetText("") GBFGuildBankUpdate() end)
	SearchEditBox:RegisterEvent("OnTextChanged")
	SearchEditBox:SetScript("OnTextChanged", function() GBFGuildBankUpdate() end)
end

function GBFMiniLvLFrameCreate()
	iLvLMinLabel=GuildBankFrame:CreateFontString("$parentText","ARTWORK","SystemFont_Outline_Small")
	iLvLMinLabel:SetPoint("TOPLEFT",GuildBankFrame,"TOPLEFT",155,-47)
	iLvLMinLabel:SetText(L["MinLvL"])
	MiniLvLEditBox=CreateFrame("EditBox","MiniLvLEditBox",GuildBankFrame,"InputBoxTemplate")
	MiniLvLEditBox:SetWidth(35);MiniLvLEditBox:SetHeight(20)
	MiniLvLEditBox:SetPoint("TOPLEFT",GuildBankFrame,"TOPLEFT",200,-42)
	MiniLvLEditBox:EnableMouse(true)
	MiniLvLEditBox:SetMultiLine(false)
	MiniLvLEditBox:SetAutoFocus(false)
	MiniLvLEditBox:SetFontObject(GameFontNormalSmall)
	MiniLvLEditBox:SetJustifyH("LEFT") 
	MiniLvLEditBox:RegisterEvent("OnEnterPressed")
	MiniLvLEditBox:SetScript("OnEnterPressed", function() MiniLvLEditBox:ClearFocus()  GBFGuildBankUpdate() end )
	MiniLvLEditBox:RegisterEvent("OnEscapePressed")
	MiniLvLEditBox:SetScript("OnEscapePressed", function() MiniLvLEditBox:ClearFocus()  MiniLvLEditBox:SetText("") GBFGuildBankUpdate() end)
	MiniLvLEditBox:RegisterEvent("OnTextChanged")
	MiniLvLEditBox:SetScript("OnTextChanged", function() GBFGuildBankUpdate() end)
end

function GBFMaxiLvLFrameCreate()
	iLvLMaxLabel=GuildBankFrame:CreateFontString("$parentText","ARTWORK","SystemFont_Outline_Small")
	iLvLMaxLabel:SetPoint("TOPLEFT",GuildBankFrame,"TOPLEFT",235,-47)
	iLvLMaxLabel:SetText(L["MaxLvL"])
	MaxiLvLEditBox=CreateFrame("EditBox","MaxiLvLEditBox",GuildBankFrame,"InputBoxTemplate")
	MaxiLvLEditBox:SetWidth(35);MaxiLvLEditBox:SetHeight(20)
	MaxiLvLEditBox:SetPoint("TOPLEFT",GuildBankFrame,"TOPLEFT",280,-42)
	MaxiLvLEditBox:EnableMouse(true)
	MaxiLvLEditBox:SetMultiLine(false)
	MaxiLvLEditBox:SetAutoFocus(false)
	MaxiLvLEditBox:SetFontObject(GameFontNormalSmall)
	MaxiLvLEditBox:SetJustifyH("LEFT") 
	MaxiLvLEditBox:RegisterEvent("OnEnterPressed")
	MaxiLvLEditBox:SetScript("OnEnterPressed", function() MaxiLvLEditBox:ClearFocus()  GBFGuildBankUpdate() end )
	MaxiLvLEditBox:RegisterEvent("OnEscapePressed")
	MaxiLvLEditBox:SetScript("OnEscapePressed", function() MaxiLvLEditBox:ClearFocus()  MaxiLvLEditBox:SetText("") GBFGuildBankUpdate() end)
	MaxiLvLEditBox:RegisterEvent("OnTextChanged")
	MaxiLvLEditBox:SetScript("OnTextChanged", function() GBFGuildBankUpdate() end)
end

-- Start of Dropdown menu functions for "iSubType" Filter

function DDItemSubTypeMenuCreation()
	DDItemSubTypeMenu = CreateFrame("Frame", "DDItemSubTypeMenu", GuildBankFrame, "UIDropDownMenuTemplate"); 
	DDItemSubTypeMenu:SetPoint("TOPRIGHT",GuildBankFrame,"TOPRIGHT",-3,-37); --This is the only frame inherited method along with Frame:Show() and Frame:Hide() 
	UIDropDownMenu_SetWidth(DDItemSubTypeMenu, 80) --Sets the width of DDItemSubTypeMenu to 80 pixels. When DDItemSubTypeMenu is orignally created, it has a default width. If the default width is not appropriate, then this function is the one for you. 
	UIDropDownMenu_SetButtonWidth(DDItemSubTypeMenu, 20) --Changes the drop down menu button with from it's default width to 20 pixels 
	UIDropDownMenu_Initialize(DDItemSubTypeMenu, DDItemSubTypeMenu_Initialise); --The virtual drop down menu will now call the function DDItemSubTypeMenu_Initialize to setup the menu items for DDItemSubTypeMenu 
end

function DDItemSubTypeMenuItem_OnClick() -- See note 1
	DOut("ItemSubTypeMenu:" , this.value," Selected")
	UIDropDownMenu_SetSelectedValue(this.owner, this.value);
	if (this.value == 0) then  
		FilterSubType = nil
	elseif (this.value == 1) then
		FilterSubType = "Cloth"
	elseif (this.value == 2) then
		FilterSubType = "Leather"
	elseif (this.value == 3) then
		FilterSubType = "Mail"
	elseif (this.value == 4) then
		FilterSubType = "Plate"
	else
		FilterSubType = nil
	end
	GBFGuildBankUpdate()
end

function DDItemSubTypeMenu_Initialise()
	level = level or 1 --drop down menus can have sub menus. The value of "level" determines the drop down sub menu tier.
   
	local info = UIDropDownMenu_CreateInfo();
    
	MenuList1 = 	{
		[0] = L["All Armor"],
		[1]	= L["Cloth"],
		[2]	= L["Leather"],
		[3]	= L["Mail"],
		[4]	= L["Plate"],
	}

	for MenuEntries = 0, table.getn(MenuList1) do
		info.text = MenuList1[MenuEntries] ; --the text of the menu item
		info.value = MenuEntries; -- the value of the menu item. This can be a string also.
		info.func = function() DDItemSubTypeMenuItem_OnClick() end; --sets the function to execute when this item is clicked
		info.owner = this:GetParent(); --binds the drop down menu as the parent of the menu item. This is very important for dynamic drop down menues.
		info.checked = nil; --initially set the menu item to being unchecked with a yellow tick
		info.icon = nil; --we can use this to set an icon for the drop down menu item to accompany the text
		UIDropDownMenu_AddButton(info, level); --Adds the new button to the drop down menu specified in the UIDropDownMenu_Initialise function. In this case, it's DDItemSubTypeMenu
	end
end


-- Start of Dropdown menu functions for "Slot" Filter
function DDItemSlotMenuCreation()
	DDItemSlotMenu = CreateFrame("Frame", "DDItemSlotMenu", GuildBankFrame, "UIDropDownMenuTemplate"); 
	DDItemSlotMenu:SetPoint("TOPRIGHT",GuildBankFrame,"TOPRIGHT",-108,-37); --This is the only frame inherited method along with Frame:Show() and Frame:Hide() 
	UIDropDownMenu_SetWidth(DDItemSlotMenu, 80) --Sets the width of DDItemSlotMenu to 80 pixels. When DDItemSlotMenu is orignally created, it has a default width. If the default width is not appropriate, then this function is the one for you. 
	UIDropDownMenu_SetButtonWidth(DDItemSlotMenu, 20) --Changes the drop down menu button with from it's default width to 20 pixels 
	UIDropDownMenu_Initialize(DDItemSlotMenu, DDItemSlotMenu_Initialise); --The virtual drop down menu will now call the function DDItemSlotMenuu_Initialize to setup the menu items for DDItemSlotMenuu 
end

function DDItemSlotMenu_Initialise()
	level = level or 1 --drop down menus can have sub menus. The value of "level" determines the drop down sub menu tier.
   
	local info = UIDropDownMenu_CreateInfo();
    
	MenuList2 = 	{
		[0] 		= L["All Slots"],
		[1]		= L["Two-Hand"],
		[2]		= L["Ammo"],
		[3]		= L["Bag"],
		[4]		= L["Shirt"],
		[5]		= L["Chest"],
		[6]		= L["Back"],
		[7]		= L["Feet"],
		[8]		= L["Finger"],
		[9]		= L["Hands"],
		[10]	= L["Head"],
		[11]	= L["Held In Off-hand"],
		[12]	= L["Legs"],
		[13]	= L["Neck"],
		[14]	= L["Quiver"],
		[15]	= L["Ranged"],
		[16]	= L["RangedRight"],
		[17]	= L["Relic"],
		[18]	= L["Robe"],
		[19]	= L["Shield"],
		[20]	= L["Shoulder"],
		[21]	= L["Tabard"],
		[22]	= L["Thrown"],
		[23]	= L["Trinket"],
		[24]	= L["Waist"],
		[25]	= L["One-Hand"],
		[26]	= L["Main Hand"],
		[27]	= L["Off Hand"],
		[28]	= L["Wrist"],
	}

	for MenuEntries = 0, table.getn(MenuList2) do
		info.text = MenuList2[MenuEntries] ; --the text of the menu item
		info.value = MenuEntries; -- the value of the menu item. This can be a string also.
		info.func = function() DDItemSlotMenu_OnClick() end; --sets the function to execute when this item is clicked
		info.owner = this:GetParent(); --binds the drop down menu as the parent of the menu item. This is very important for dynamic drop down menues.
		info.checked = nil; --initially set the menu item to being unchecked with a yellow tick
		info.icon = nil; --we can use this to set an icon for the drop down menu item to accompany the text
		UIDropDownMenu_AddButton(info, level); --Adds the new button to the drop down menu specified in the UIDropDownMenu_Initialise function. In this case, it's DDItemSubTypeMenu
	end
end

	         
function DDItemSlotMenu_OnClick()
	DOut("ItemSlotMenu: " .. this.value .." Selected")
	UIDropDownMenu_SetSelectedValue(this.owner, this.value);
	if (this.value == 0) then  --
		FilterSlot = nil
	elseif (this.value == 1) then
		FilterSlot = "INVTYPE_2HWEAPON"
	elseif (this.value == 2) then
		FilterSlot = "INVTYPE_AMMO"
	elseif (this.value == 3) then
		FilterSlot = "INVTYPE_BAG"
	elseif (this.value == 4) then
		FilterSlot = "INVTYPE_BODY"
	elseif (this.value == 5) then
		FilterSlot = "INVTYPE_CHEST"
	elseif (this.value == 6) then
		FilterSlot = "INVTYPE_CLOAK"
	elseif (this.value == 7) then
		FilterSlot = "INVTYPE_FEET"
	elseif (this.value == 8) then
		FilterSlot = "INVTYPE_FINGER"
	elseif (this.value == 9) then
		FilterSlot = "INVTYPE_HAND"
	elseif (this.value == 10) then
		FilterSlot = "INVTYPE_HEAD"
	elseif (this.value == 11) then
		FilterSlot = "INVTYPE_HOLDABLE"
	elseif (this.value == 12) then
		FilterSlot = "INVTYPE_LEGS"
	elseif (this.value == 13) then
		FilterSlot = "INVTYPE_NECK"
	elseif (this.value == 14) then
		FilterSlot = "INVTYPE_QUIVER"
	elseif (this.value == 15) then
		FilterSlot = "INVTYPE_RANGED"
	elseif (this.value == 16) then
		FilterSlot = "INVTYPE_RANGEDRIGHT"
	elseif (this.value == 17) then
		FilterSlot = "INVTYPE_RELIC"
	elseif (this.value == 18) then
		FilterSlot = "INVTYPE_ROBE"
	elseif (this.value == 19) then
		FilterSlot = "INVTYPE_SHIELD"
	elseif (this.value == 20) then
		FilterSlot = "INVTYPE_SHOULDER"
	elseif (this.value == 21) then
		FilterSlot = "INVTYPE_TABARD"
	elseif (this.value == 22) then
		FilterSlot = "INVTYPE_THROWN"
	elseif (this.value == 23) then
		FilterSlot = "INVTYPE_TRINKET"
	elseif (this.value == 24) then
		FilterSlot = "INVTYPE_WAIST"
	elseif (this.value == 25) then
		FilterSlot = "INVTYPE_WEAPON"
	elseif (this.value == 26) then
		FilterSlot = "INVTYPE_WEAPONMAINHAND"
	elseif (this.value == 27) then
		FilterSlot = "INVTYPE_WEAPONOFFHAND"
	elseif (this.value == 28) then
		FilterSlot = "INVTYPE_WRIST"
	else
		FilterSlot = nil
	end
	DOut("FilterSlot variable set to: ",FilterSlot)
	GBFGuildBankUpdate()
end

-- ** Define Slash Commands - None Declared!  **
--[[  
SLASH_bcsGBF1 = "/GBF"
SlashCmdList["bcsGBF"] = bcsGBF_Command
]]-- 

-- Main Code for Addon Begins here trigger for main code is the saved variables being loaded
local f=CreateFrame("Frame","bcsGBFLoaded")
f:RegisterEvent("GUILDBANKBAGSLOTS_CHANGED")
f:SetScript("OnEvent", GBF_OnEvent)
